'''
Author: Leo.wang wanglizhigs@163.com
Date: 2025-09-05 20:36:08
LastEditors: Leo.wang wanglizhigs@163.com
LastEditTime: 2025-09-05 21:17:30
FilePath: /medical-companion-server-python/app/order/serializers.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
from rest_framework import serializers
from .models import McOrder, McUser, McPatient, McService, McGender, McOrderStatus
from app.user.serializers import McForeignUserSerializer
from app.patient.serializers import McForeignPatientSerializer
from app.service.serializers import McForeignServiceSerializer
from app.gender.serializers import McGenderSerializer
from app.order_status.serializers import McForeignOrderStatusSerializer


class McServiceSerializer(serializers.ModelSerializer):
    user = McForeignUserSerializer(read_only=True)
    patient = McForeignPatientSerializer(read_only=True)
    service = McForeignServiceSerializer(read_only=True)
    companion_gender = McGenderSerializer(read_only=True)
    status = McForeignOrderStatusSerializer(read_only=True)


    user_id = serializers.PrimaryKeyRelatedField(
        queryset=McUser.objects.all(), source="user", write_only=True
    )
    patient_id = serializers.PrimaryKeyRelatedField(
        queryset=McPatient.objects.all(), source="patient", write_only=True
    )
    service_id = serializers.PrimaryKeyRelatedField(
        queryset=McService.objects.all(), source="service", write_only=True
    )
    companion_gender_id = serializers.PrimaryKeyRelatedField(
        queryset=McGender.objects.all(), source="companion_gender", write_only=True
    )
    status_id = serializers.PrimaryKeyRelatedField(
        queryset=McOrderStatus.objects.all(), source="status", write_only=True
    )
 

    class Meta:
        model = McOrder
        fields = '__all__'